Imports BusinessLogicLayer

Public NotInheritable Class frmErrorViewer

    Const iCollapsedHeight As Integer = 194
    Const iExpandedHeight As Integer = 354
    Dim _BLDisposer As New BLDisposer(Handle)
    Dim exViewer As Exception
    Dim sExMethodName As String
    Dim bCollapsedDetails As Boolean = True
    Dim oException As Exception

    Private Sub frmExceptionViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '' ''Me.Text = "ERROR: " & sExMethodName
        '' ''lblExMessage.Text = exViewer.Message
        '' ''lblMethodName.Text = sExMethodName
        '' ''txtExDetails.Text = Replace(txtExDetails.Text, "sExceptionMessage", sExMethodName.ToString)
        '' ''txtExDetails.Visible = False
        Me.Height = iCollapsedHeight
    End Sub

    ''' <summary>
    ''' NO COMMENTS
    ''' </summary>
    ''' <param name="ex">Exception</param>
    ''' <param name="sInitiatorMethod">Method name which initiated the process causing the error</param>
    ''' <param name="sExceptionSource">Method name that raised the error</param>
    ''' <param name="sFileDetails">File details of exception source</param>
    ''' <remarks></remarks>
    Public Sub New(ByVal ex As Exception, ByVal sInitiatorMethod As String, _
    ByVal sExceptionSource As String, ByVal sFileDetails As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        'Initialize() ':: Title/other controls via NEW

        'MessageBox.Show("Error: " & ex.Message & vbCrLf & vbCrLf & "Details:" & vbCrLf & ex.ToString, "Error: GUIPopulator.SearchByView", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Me.Text = "ERROR: " & sInitiatorMethod
        lblExMessage.Text = ex.Message
        lblMethodName.Text = sInitiatorMethod
        oException = ex
        ' = sExceptionSource
        txtExDetails.Text = Replace(txtExDetails.Text, "sExceptionMessage", ex.ToString)
        'txtExDetails.Visible = False
    End Sub

    Protected Overrides Sub Finalize()
        _BLDisposer.Dispose()
        MyBase.Finalize()
    End Sub

    Private Sub btnDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetails.Click
        'Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable
        'If Me.Height = iCollapsedHeight Then Me.Height = iExpandedHeight
        'If Me.Height = iExpandedHeight Then Me.Height = iCollapsedHeight
        'Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.Height = CInt(IIf(bCollapsedDetails, iCollapsedHeight, iExpandedHeight))
        bCollapsedDetails = Not bCollapsedDetails
    End Sub

    Private Sub btnContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnContinue.Click
        Me.Close()
    End Sub

    Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
        End
    End Sub

    Private Sub btnCopyClipboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyClipboard.Click
        Select Case MsgBox("You sure??", MsgBoxStyle.YesNo, lblMethodName.Text)
            Case MsgBoxResult.Yes : My.Computer.Clipboard.SetText(oException.Message & vbCrLf & vbCrLf & oException.ToString)
            Case MsgBoxResult.No 'Do Nothing
        End Select
    End Sub
End Class